{% extends 'base.html' %}

{% block content %}
<h4>作业提交列表</h4>
<a href="{% url 'core:homework_submission_create' %}" class="btn btn-primary mb-3">创建新作业提交</a>

{% if is_paginated %}
  <div class="pagination mb-3">
    <span class="step-links">
      {% if page_obj.has_previous %}
        <a href="?page=1" class="btn btn-sm btn-outline-secondary">&laquo; 第一页</a>
        <a href="?page={{ page_obj.previous_page_number }}" class="btn btn-sm btn-outline-secondary">上一页</a>
      {% endif %}

      <span class="current">
        第 {{ page_obj.number }} 页，共 {{ page_obj.paginator.num_pages }} 页
      </span>

      {% if page_obj.has_next %}
        <a href="?page={{ page_obj.next_page_number }}" class="btn btn-sm btn-outline-secondary">下一页</a>
        <a href="?page={{ page_obj.paginator.num_pages }}" class="btn btn-sm btn-outline-secondary">最后一页 &raquo;</a>
      {% endif %}
    </span>
  </div>
{% endif %}

<div class="table-responsive"><table class="table table-striped table-hover">
    <thead>
        <tr>
            <th>学生</th>
            <th>作业</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {% for submission in submissions %}
        <tr>
            <td>{{ submission.student }}</td>
            <td>{{ submission.homework }}</td>
            <td>{{ submission.get_status_display }}</td>
            <td>
                <a href="{% url 'core:homework_submission_update' submission.pk %}" class="btn btn-sm btn-secondary me-2">编辑</a>
                <a href="{% url 'core:homework_submission_delete' submission.pk %}" class="btn btn-sm btn-danger">删除</a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table></div>
{% endblock %}